package emulator.shell.GUI.IECwindow;

import java.util.Vector;

import javax.swing.table.AbstractTableModel;

public class DeviceTableModel extends AbstractTableModel {
	
	String[] column_names = {
    		"En",
            "#",
            "Type",
            "File"
           	};
	
	int[] column_widths = {
			20,
			20,
			70,
			100
	};
	
	Vector<DeviceInfo> devices = new Vector<DeviceInfo>();

	public DeviceTableModel()
	{
		devices.add(new DeviceInfo(4, "printer", "(null)"));
		devices.add(new DeviceInfo(8, "disk", "."));
	}

	@Override
	public int getColumnCount() {
		return column_names.length;
	}

	@Override
	public String getColumnName(int column) {
		return column_names[column];
	}

	public int getColumnWidth(int col)
	{
		return column_widths[col];
	}

	@Override
	public int getRowCount() {
		return devices.size();
	}

	@Override
	public Object getValueAt(int row, int column) {
		switch (column)
		{
		case 0:	return devices.get(row).isEnabled();
		case 1: return devices.get(row).getAddress();
		case 2: return devices.get(row).getType();
		case 3: return devices.get(row).getFile();
		}
		return null;
	}

	@Override
	public boolean isCellEditable(int row, int column) {
		return column == 0;
	}

	@Override
	public Class<?> getColumnClass(int col) {
		return getValueAt(0, col).getClass();

	}

	@Override
	public void setValueAt(Object value, int row, int column) {
		// TODO Auto-generated method stub

	}

	private static final long serialVersionUID = 4776849022812402994L;
}
